<!--
*@Author: QWP
*@Description: 创建群聊
*@Date: 2024-07-08 17:04:38
-->
<template>
  <u-dialog v-bind="$attrs" 
    :confirmLoading="loading" 
    @close="dialogClose" 
    @submit="submit">
    <Edit ref="formRef" 
      :keyid="keyid"
      @success="(data) => emits('success', data)"/>
  </u-dialog>
</template>

<script lang='ts' setup>
import { ref, reactive, computed, onMounted, h, watch, useAttrs, nextTick } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useLoginStore } from '@/store'
import { storeToRefs } from 'pinia'
import { _IFormEl, _IExtra } from '@/src/components/common/form/interface';
import { FormInstance, FormItemProps } from 'ant-design-vue';
import { messageC } from '@/util/common';
import * as groupApi from '@/service/emergency/group'
import * as unitApi from '@/service/system/unit'
import * as travelApi from "@/service/administration/travel";
import Edit from './Edit.vue'
import dayjs from 'dayjs'

const props = defineProps<{
  keyid?: string
}>()

const attrs = useAttrs()
const emits = defineEmits(['success', 'close'])

const formRef = ref<FormInstance>()

const loading = computed(() => {
  if(formRef.value) {
    return formRef.value.loading
  }
})

// 提交保存
const submit = () => {
  formRef.value.submit();
}

// 弹窗关闭
const dialogClose = () => {
  formRef.value.dialogClose();
  emits('close')
}

watch(() => attrs.open, async (nval, oval) => {
  if (nval == true && !props.keyid) {
    nextTick(() => {
      formRef.value.initShow(nval)
    })
  }
})
</script>

<style lang='scss'></style>